package com.mall.common;

import com.google.common.collect.Sets;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Set;

@Component
//公共常量 用来增加密码的复杂度
public class Constant {



    //系统常量
//    接口中的变量都是公有的静态常量
    public interface System{
        public static final String SALT = "abc98@.,72.,";
    }
    //用户常量
    public interface User{
        public static final String CURRENT_USER = "currentUser";
        Integer IS_ADMIN = 2;
        Integer IS_USER = 1;
    }
    //上传目录
    public static String UPLOAD_DIR;

    @Value("${upload-dir}")
    public void setUploadDir(String uploadDir){
        UPLOAD_DIR=uploadDir;
    }
    //定义商品的排序字段
    public interface ProductListOrderBy{
        Set<String> set = Sets.newHashSet("price asc","price desc");
    }
    public interface  CartSelected{
        int NOT_SELECT=0;
        int SELECTED=1;

    }
    public interface  SellStatus{
        int NOT_SELL=0;
        int SELL=1;
    }
    //定义订单支付状态
    public enum OrderStatusEnum{
        CANCELED(0,"已取消"),
        NOT_PAID(10,"未付款"),
        PAID(20,"已付款"),
        DELIVERED(30,"已发货"),
        FINISHED(40,"已完成");
        public static String getMessage(Integer code){
            if(code==0){
                return "已取消";
            } else if(code==10){
                return "未付款";
            } else if(code==20){
                return "已付款";
            } else if(code==30){
                return "已发货";
            } else if(code==40){
                return "已完成";
            }
            return null;
        }
        private Integer code;
        private String value;

        OrderStatusEnum(Integer code, String value) {
            this.code = code;
            this.value = value;
        }

        public Integer getCode() {
            return code;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }
    }
}
